<template>
  <!-- id="components-layout-demo-custom-trigger" -->
  <a-layout id="components-layout-demo-fixed-sider">
    <a-layout-sider
      v-model="collapsed"
      :trigger="null"
      collapsible
      :style="{ overflow: 'auto', height: '100vh', position: 'fixed', left: 0 }"
    >
      <sider-menu />
    </a-layout-sider>
    <a-layout style="transition: all 0.2s" :style="{  marginLeft: !collapsed ? '200px' : '80px'}">
      <a-layout-header style="background: #fff; padding: 0;border-bottom:1px solid #eee;">
        <Header />
      </a-layout-header>
      <a-layout-content :style="{}">
        <a-spin :spinning="loading">
          <router-view></router-view>
        </a-spin>
        <!-- <router-view></router-view> -->
      </a-layout-content>
    </a-layout>
  </a-layout>
</template>
<script>
import { mapState } from "vuex";
import SiderMenu from "@/components/SiderMenu";
import Header from "@/components/Header";
import Bus from "@/utils/bus";
export default {
  data() {
    return {
      collapsed: false,
    };
  },
  components: {
    SiderMenu,
    Header,
  },
  computed: {
    ...mapState({
      loading: (state) => state.base.loading,
    }),
  },
  created() {
    // 通过 Event Bus 进行组件间通信，来折叠侧边栏
    Bus.$on("collapsed", (msg) => {
      this.collapsed = msg;
    });
  },
};
</script>
<style lang="less" scoped>
@import "~@/assets/css/base.less";
</style>
